logo
down
shadow

How do I download a batch of pictures from URLs stored in a MySQL database


How do I download a batch of pictures from URLs stored in a MySQL database

By : user2956825
Date : November 22 2020, 03:03 PM
it should still fix some issue I have a database containing pictures URLs that looks like this:
code :
set_time_limit(1000);    
while( $url = $response->fetch() ) {
    $my_image = file_get_contents('http://aaafg.com/im.jpg');
    $my_file = fopen('path/myData.jpg','w+');// you must change image name
    fwrite($my_file,$my_image);
    fclose($my_file);
    }


Share : facebook icon twitter icon
download .doc files from .csv containing urls, then batch convert them to plain text

download .doc files from .csv containing urls, then batch convert them to plain text


By : Rahul Vijay
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I decided to stay away from python with these beginning steps, so used wget to download the files and then antiword to convert all the .doc files to .txt.
PHP-unable to download a .pdf file from database , file content is stored in mysql database

PHP-unable to download a .pdf file from database , file content is stored in mysql database


By : Nick Zubariev
Date : March 29 2020, 07:55 AM
this one helps. The main reason why page is changing into gray colors is that the browser is unable to detect content type correctly.
Try this:
code :
header("Content-type: $mimetype");
header('Content-Disposition: inline; filename="'.$question.'"'); // Filename should be there, not the content
header('Content-type: $mimetype');
header('Content-Disposition: inline; filename="$question"');
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename=anything.pdf');
header('Content-Transfer-Encoding: binary');
echo $question;
$mimetype = 'application/pdf';
$disposition = 'attachment';

// First error: you have single quotes here. So output is 'Content-type: $mimetype' instead of the 'Content-type: application/pdf'
header('Content-type: $mimetype');

// Second error. Quotes again. Additionally, $question is CONTENT of your PDF, why is it here?
header('Content-Disposition: inline; filename="$question"');


header('Content-Transfer-Encoding: binary');

// Also bad: strlen() for binary content? What for?
header('Content-length: ' . strlen($question));


header('Accept-Ranges: bytes');
echo "$question";
$year = '2013'; // Assign value
header('Content-Disposition: inline; filename='.$year.'.pdf');
header('Content-Disposition: inline; filename=anything.pdf');
Batch download URLs in PHP?

Batch download URLs in PHP?


By : Anthony Jayasekera
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , When you iterate over an SplFileObject, you get the whole line, including whitespace. Your URL will thus be something like
code :
http://example.com/_
<?php
$file_tmp = "urls.txt";
$save_loc = "sav/";

$parts = new SplFileObject($file_tmp);
foreach($parts as $line) {
    $url = trim($line);
    if (!$url) {
        continue;
    }
    $dir = "{$save_loc}".basename($url);
    $raw = file_get_contents($url);
    if ($raw === false) {
        echo 'failed to donwload ' . $url . "\n";
        continue;
    }
    file_put_contents($dir, $raw);
}
Get pictures that stored in database to picture box

Get pictures that stored in database to picture box


By : brothertoad
Date : March 29 2020, 07:55 AM
I hope this helps . Your problem source is the way you save pictures to the database. When you build insert command, here is what will be inserted as the image:
code :
"Insert into Menu values ( 'someCategory','someItemname',42,'System.Byte[]')"
                                                                   ^
var insertMenuQuery = "INSERT INTO Menu VALUES(@category, @itemName, @price, @image)";
SqlCommand cmd = new SqlCommand(insertMenuQuery, con);
cmd.Parameters.AddWithValue("@category", category);
cmd.Parameters.AddWithValue("@itemName", itemName);
cmd.Parameters.AddWithValue("@price", price);
cmd.Parameters.AddWithValue("@image", image);
// or cmd.Parameters.Add("@image", SqlDbType.VarBinary).Value = image;
Python: How to download images with the URLs in the excel and replace the URLs with the pictures?

Python: How to download images with the URLs in the excel and replace the URLs with the pictures?


By : Aeizii
Date : March 29 2020, 07:55 AM
around this issue I hope this answers your question:
Write a loop over the rows using Pandas library; you might find https://pandas.pydata.org/pandas-docs/version/0.23/generated/pandas.read_excel.html and How to iterate over rows in a DataFrame in Pandas? interesting. Within every iteration save the corresponding picture into a folder (maybe name them with your Pandas index); Refer to python save image from url to learn how to save a picture from a URL. Use XlsxWriter library to put them on their respective cell; see an example at https://xlsxwriter.readthedocs.io/example_images.html
Related Posts Related Posts :
  • PHP - Prevent client from tampering the ID of a form
  • unexpected T_PUBLIC error
  • Types of testcases in PHPUnit
  • keeping a LDAP user logged in with PHP session
  • Detect if browser supports WebP format? (server side)
  • real_escape_string not cleaning up entered text
  • E-commerce products filter
  • Why having more than one test method in a file using Laravel raises error?
  • PHP Escaped special characters to html
  • Basic prepared statement not INSERTING
  • PHP combobox not showing in HTML table
  • MySql PHP row request to variable
  • Join two tables with one table has multiple rows matching
  • Looping through users with Instagram API requests is REALLY slow
  • Unable to add 30 days to date within loop
  • Return from mysqli_query() into array
  • php rename() function returns "No such file or directory" error
  • form submit inside navigation menu
  • PHP: reasons to use GET and POST request at the same time?
  • Is break; required after die() php
  • little depth of session in php
  • Authentication Logon page not working using PHP and Oracle on Apache / Windows 2008
  • Magento reindexing error product flat data
  • Laravel 4: Running composer when deploying to Heroku
  • Long Polling or WebSockets
  • How to use mysqli_stmt_bind_param for integers, boolean, etc
  • Determining the content of a link
  • MYSQL and PHP update events?
  • PHP explode all square bracket
  • Transparent hexagon-masked collage using PHP GD
  • Plugins or text do NOT show up on custom wordpress template
  • inserting data into mysqli database
  • Two arguments to closure function laravel
  • UnClear image exported by ffmpeg from mp4 file
  • is the time of computer and localhost same?
  • change custom data- value after ajax post success
  • Can We Restrict PHP Variables to accept only certain type of values
  • csv file is inserting a blank row in the last of other rows into mysql table
  • How to convert special characters in xml using php?
  • Mcrypt are very confusing
  • Dynamic image for user's ID
  • How to only upload specific parts of HTML form with PHP?
  • Dynamic PHP string as MySQL table name
  • What is the error in my query?
  • PHP Upstart on Amazon EC2 Linux (Elasticbeanstalk)
  • how to print dynamic variable value in php
  • php mysql insert values and select
  • uploading image in codeigniter controller
  • Converting htaccess to nginx for counter
  • how can I show my signal transaction data as project name
  • php raspberry pi trying to change pi date
  • PHP and mysql, SELECT query return null
  • Unable to store Date values in php mysql table that are existing in excel file
  • Can we include 2 Mail() functions in 1 Page?
  • Problems with chinese characters
  • How to apply a function to every foreach result?
  • Use of CONCAT in FROM clause
  • Tag endpoint combined with user endpoint with Instagram API
  • create dynamic time in php and mysql
  • How to break zero index comma separated value into individual string in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org