-Thanks for all the help folks. turns out it was indeed my own stupidity. Table column on local db was called 'url', on web-host it was 'urls'. Apologies for wasting everyone's time!
I'm trying to make a webpage display some videos, the paths to which are in a database.
The following piece of code works fine on the Localhost (I'm using MAMP) but when I upload it to the web-server, it displays the names of the videos OK but I get "No video with supported format and MIME type found." in Firefox. Chrome and Safari both stall while loading.
$result=mysql_query("SELECT * FROM videos");
while($row = mysql_fetch_array($result))
{
echo "<video width=\"600\" height=\"350\" controls=\"controls\">";
echo "<source src='".$row['url'].".mp4' type='video/mp4'/>";
echo "<source src='".$row['url'].".theora.ogv' type='video/ogg'/>";
echo "</video>";
echo "<br>" . $row['name'] ."<br/><br/>";
}
I guess it might be something obvious but I'm stumped.
Any help much appreciated.
thanks,
Robert.
Can you verify the video is in the database(name is one thing, is the file actually there?)? If using upload form, it is necessary to use enctype="multipart/form-data". I assume the videos are the format you are trying to request them as.
In your post you say "but when I upload it to the web-server", so the problem IS with the upload then, not the displaying of the videos? You seem to be saying you have a problem with the upload, but your code is the code retrieving it from the database.
So is the problem with the upload, or the display firstly.
Related
edit: To sum it all up, I wanted to see how to make a website generate a link after a file has been uploaded.
First time posting here, I hope I'm not breaking the rules by asking this, haha.
I'm trying to set up an upload function on my website by following the tutorial on tizag, but I can't seem to figure out how to make it that after uploading, the user is presented with a link to the file (like how you would upload something to imgur and receive a short link like this imgur.com/k4FzF6W ).
Thank you for your help! I'm very new to php and I'm not the best at code in general.
This all depends on if you have the button to upload and stuff BUT here is just the basics of it, since I don't know what your code is.
$fileupload = uploadedfilenamehere;
function grabLink() {
echo "site.com/".$fileupload;
}
Which would return:
"site.com/uploadedfilenamehere"
And if you need to have a directiory just change this:
echo "site.com/dir/".$fileupload;
So this is a weird phenomenon I've never experienced in that I have an HTML form on image upload (exactly the one on W3). It does it's job properly when clicked and pushes the user profile picture into a folder while saving the name of the file on a database. Underneath the upload, I have a little image tag that spits out the uploaded profile picture. The end goal is for that profile picture to be displayed on the page constantly while the session exists. When uploaded, it works perfectly fine and the profile picture appears. After one refresh, the image can't be found and the alt="blank" takes over. The location still stays proper in the database so I don't think that's the issue. Is there an error? Do I need to use JS onload? Does the image tag only work once? Please help and thank you for taking the time to read this.
PHP:
echo '<img src="'.$loaded_profile_picture.'"id="HOMEPROFILE" alt="blank" style="width:128px;height:128px">';
//$loaded_profile_picture has the value uploads/photo.jpg
Classes.php:
public function addProfilePicture(){
include_once "conn.php";
$sql=$dbh->prepare("UPDATE users SET UserProfilePicture=:UserProfilePicture WHERE UserName=:UserName;");
$sql->execute(array(
'UserProfilePicture'=>$this->getUserProfilePicture(),
'UserName'=>$_SESSION['UserName'],
));
}
Image Upload (Might be the culprit):
if($uploadsuccess&&move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_file)){
echo " The file ".basename($_FILES['fileToUpload']['name'])." has been uploaded.";
$user->setUserProfilePicture($target_file);
$user->addProfilePicture();
if($user->getUserProfilePicture()!=NULL){
echo '<img src="'.$target_file. '" alt="nom">';
}
}
Edit:
While many users have a similar problem (i.e. Image display with <img src=""> not working) I have tried looking at localhost:8888/xampp/LocalPost/pages/uploads/photos.jpg and it displays just fine. I have also changed file permissions on Windows 7 with no luck. Thanks for all your hard work I'll keep searching.
Edit:
I got around the problem by using $_SESSION['UserProfilePicture'] and it sticks after a refresh. This doesn't solve the question. I'd still very much like someone to help me find what went wrong, because later on I would like to display other people's Profile Pictures which you obviously can't do with session variables.
first of all your missing } et the end of your script
if($uploadsuccess && move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_file)){
echo " The file ".basename($_FILES['fileToUpload']['name'])." has been uploaded.";
$user->setUserProfilePicture($target_file);
$user->addProfilePicture();
if($user->getUserProfilePicture()!=NULL){
echo '<img src="'.$target_file. '" alt="nom">';
}
}
Check once that after refreshing your page you will be get the value of $loaded_profile_picture variable or not?
If you got the value of $loaded_profile_picture variable then check it is same as your previous path or not?
I have a perfectly working setup of FPFD on my localhost(windows) it generates the pdf files alright. However, when i uploaded to the production environment(Linux), it throws this silly error.
I have been trying to trouble shoot for the past 2hrs now. the error does not give any pointers as to where the stream is suddenly ending. Have posted on their forum but that place looks dead to me.
Please who has used or encountered this error before?
Any help will be greatly appreciated.
After hours and days or researching, I found that a png image I was trying to use was not uploaded successfully....it was partially uploaded....I minified the image and reuploaded, and the error disappeared.
This error occur because of the image is not completely uploaded to the particular folder you are storing . Example-> creating an image but that image is not complete then it will give this error . so in this case first check that image is there or not and then put the static url to the pdf->image('static url which you can see in you web browser',0,0,-72) and the check it or else use any web image url to check it .
And when your have space or dot in you url that you are creating after uploading Example-> https://adc.com/ xyz .png it will also create the same problem .
i have problem with uploading on my own server with nicEdit wysiwyg editor.
When you clikc on upload image you will upload image on other site. Here: imgur dot com
This is it: http://nicedit.com/demos.php
I want to use them php script to upload image on my own server/domain.
Can somebody tell me how to do it?
Here is the script: http://svn.nicedit.com//trunk/nicUpload/php/nicUpload.php
Still show message "Failed to upload image".
In console on firebug show this one:
<script>
try {
top.nicUploadButton.statusCb({"error":"Invalid Upload ID"});
} catch(e) { alert(e.message); }
</script>
POST is okay but i dont understand this. :(
Have anybody som good answer for me?
Thank you very buch.
PS: sorry for my english. :)
Daniel.
Did you install the PHP APC library on your server? I think you need to generate this id.
$id = $_POST['APC_UPLOAD_PROGRESS'];
NicEditor uses imgur as the default image upload service. The source code follows the API format described here: http://api.imgur.com/resources_anon#upload
My suggestion would be to implement the API request and response defined there.
I've tried the native way of uploading images with PHP, but my friend suggested me to the class.upload.php library, which still had the same results as before. I can only upload certain images without them having that little icon that means that the browser can't find the image, but what's weird is that when I download the "invalid" images to my computer, they're fine. About 50% of images actually do work, but the rest just show the appropriate size that they should have but no image. Here is my code (my html form has a file input type called filename:
$handle = new upload($_FILES['filename']);
if ($handle->uploaded)
{
if ($file_src_size < 20000)
{
$handle->file_new_name_body = "test";
$handle->image_convert = 'jpg';
$handle->process('/');
echo "<img src = \"test.jpg\" />";
}
else echo "Files must be 20 kb or under";
}
else echo "Upload failed, please try again";
The fact that you can download the images and re-display locally them suggests that the problem is not with the upload script. An alternative problem could be that the images are not properly saved for web viewing. For example, just because a file ends in .jpg and can be viewed locally does not mean that it is recognizable by a browser. A CMYK jpeg cannot be viewed by many browsers.
You need to debug your code as something is going wrong, and only someone with access to your computer can tell you why.
1) The library you're using has error detection code
if ($handle->processed) {
echo 'image resized';
$handle->clean();
} else {
echo 'error : ' . $handle->error;
}
2) You should be able to look at the processed image data, and figure out why the browser is not able to parse it as an image. If you can give a URL for an invalid image I would be able to tell you what's wrong with it.
3) Writing files to the root directory by calling "process('/');" is bad. You should make a directory to hold files that come from other people, to avoid having potential problems when some uploads an image called 'index.php'.